package com.leave.service;
import com.leave.dao.ClassesDao;
import com.leave.entity.Classes;

import java.sql.SQLException;
import java.sql.SQLOutput;
import java.util.List;
import java.util.Map;

public class ClassesService {
    private ClassesDao classesDao;
    public void setClassesDao(ClassesDao classesDao) {
        this.classesDao = classesDao;
    }

    public List<Classes> classesList(Classes classes){
        List<Classes> cla_list = null;
        cla_list = classesDao.query(classes);
        return cla_list;
    }

    public boolean deleteClass(String classID){
        classesDao.delete(classID);
        return true;
    }

//    public List<Classes> seek(String classID) {
//        Classes classes = new Classes();
//        classes.setClassID(classID);
//        List<Classes> list = classesDao.query(classes);
//        return list;
//    }

    public List<Map<String, Object>> seek(String keyword) throws SQLException {
        if(keyword != null){
            return classesDao.selectClassesList(keyword);
        }else{
            return null;
        }
    }

    public boolean addClass(Classes classes){
        classesDao.insert(classes);
        return true;
    }

    public boolean editClass(Classes classes) {
        classesDao.update(classes);
        return true;
    }
}
